package com.actividadad.uno;

import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Label;
import java.awt.Scrollbar;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;

public class Ejercicio2 extends Applet implements AdjustmentListener {

	Scrollbar Scrb1,Scrb2,Scrb3 ;
	int barra1 = 0,barra2 = 0,barra3 = 0;
	Label LblScroll1,LblScroll2,LblScroll3;

	
	 public void paint(Graphics g) {
		
		  Color valor= new Color(barra1, barra2, barra3);
	      System.out.println("Cree un nuevo color" + valor.toString());
		  g.drawRect(0, 0, 500, 500);
	      g.fillRect(0, 0, 500, 500);
	      g.setColor(valor);
	      System.out.println("puse un nuevo color" +valor.toString() );
	   }
	
	public Ejercicio2(){

		Scrb1 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 256);
		Scrb2 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 256);
		Scrb3 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 256);
		add(Scrb1);
		add(Scrb2);
		add(Scrb3);
		LblScroll1 = new Label("Deslizador1 = " );
		LblScroll2 = new Label("Deslizador2 = " );
		LblScroll3 = new Label("Deslizador3 = " );
		add (LblScroll1);
		add (LblScroll2);
		add (LblScroll3);
		Scrb1.addAdjustmentListener(this);
		Scrb2.addAdjustmentListener(this);
		Scrb3.addAdjustmentListener(this);
	}

	@Override
	public void adjustmentValueChanged(AdjustmentEvent arg0) {
		barra1 = Scrb1.getValue();
		barra2= Scrb2.getValue();
		barra3 = Scrb3.getValue();
		repaint();
		System.out.println("Pinte el nuevo color");
		LblScroll1.setText("Deslizador1 = " + barra1);
		LblScroll2.setText("Deslizador2 = " + barra2);
		LblScroll3.setText("Deslizador3 = " + barra3);
	}
}
